//  眼部检测及关键点API
exports.animation = async (context) => {
  const { userId, imageUrl } = context.data
  const result = await context.cloud.httpApi.invoke(
    {
      'domain': 'https://lamer-jf.morefun.me',
      'path': '/api/lamer/animation',
      'body': {
        "paramsData": JSON.stringify({ "userId": userId, "imageUrl": imageUrl })
      },
      'method': 'POST',
      'headers': {
        'Content-Type': 'application/json;charset=UTF-8',
      }
    });
  return JSON.parse(result)
}

//  商品列表
exports.getItemList = async (context) => {
  const result = await context.cloud.httpApi.invoke(
    {
      'domain': 'https://lamer-jf.morefun.me',
      'path': '/api/item/getItemList',
      'body': {
        "paramsData": "{\"source\":\"tb\"}" //来源平台,微信:wx 微博:wb 淘宝:tb
      },
      'method': 'POST',
      'headers': {
        'Content-Type': 'application/json;charset=UTF-8',
      }
    });
  return JSON.parse(result)
}

//  保存淘宝用户
exports.getUsers = async (context) => {
  const { mixNick, openId } = context
  const result = await context.cloud.httpApi.invoke(
    {
      'domain': 'https://lamer-jf.morefun.me',
      'path': '/api/taobao/getUsers',
      'body': {
        openId,
        mixNick
      },
      'method': 'POST',
      'headers': {
        'Content-Type': 'application/json;charset=UTF-8',
      }
    });
  return JSON.parse(result)
}

//  查询用户眼肌报告
exports.getUserEyeDetectionRecords = async (context) => {
  const { userId } = context.data
  const result = await context.cloud.httpApi.invoke(
    {
      'domain': 'https://lamer-jf.morefun.me',
      'path': '/api/lamer/getUserEyeDetectionRecords',
      'body': {
        "paramsData": JSON.stringify({ "userId": userId })
      },
      'method': 'POST',
      'headers': {
        'Content-Type': 'application/json;charset=UTF-8',
      }
    });
  return JSON.parse(result)
}

//  查询某个眼肌报告
exports.getUserEyeDetectionRecordById = async (context) => {
  const { recordId } = context.data
  const result = await context.cloud.httpApi.invoke(
    {
      'domain': 'https://lamer-jf.morefun.me',
      'path': '/api/lamer/getUserEyeDetectionRecordById',
      'body': {
        "paramsData": JSON.stringify({ "recordId": recordId })
      },
      'method': 'POST',
      'headers': {
        'Content-Type': 'application/json;charset=UTF-8',
      }
    });
  return JSON.parse(result)
}



